/*
 * @Description: config/db
 * @Author: zoeblow
 * @Email: wangfuyuan@nnuo.com
 * @Date: 2019-12-12 14:45:17
 * @LastEditors: zoeblow
 * @LastEditTime: 2019-12-12 14:48:08
 * @FilePath: \monitor-manage\config\db.js
 */
const mongoose = require("mongoose");

const url = "mongodb://localhost:27017/wang";

mongoose.connect(url);

const db = mongoose.connection;

// 连接失败
db.on("error", console.error.bind(console, "连接失败:"));
// 连接成功;
db.once("connected", function() {
  console.log("连接成功：" + url);
});

// 连接断开
db.on("disconnected", function() {
  console.log("连接已断开");
});

module.exports = mongoose;
